package de.ama.search;

import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;

/**
 * Created by IntelliJ IDEA.
 * User: x
 * Date: 20.02.11
 * Time: 00:21
 * To change this template use File | Settings | File Templates.
 */
public class Word implements Comparable{
    private String word;
    private Set ids = new TreeSet();

    public Word(String txt) {
        this.word = txt.toLowerCase();
    }

    public void addId(int id){
        if(id>0){
            ids.add(id);
        }
    }

    public Collection<Integer> getIds(){
        return ids;
    }

    public boolean matches(String search) {
        return this.word.startsWith(search);
    }

    public int compareTo(Object o) {
        if (o instanceof Word) {
            Word other = (Word) o;
            return word.compareTo(other.word);
        }
        return -1;
    }

}
